﻿using System;
using System.Windows.Forms;
using AV2BV;

namespace AVBV互转
{
    public partial class Form1 : Form
    {
        /*参考
		https://www.bilibili.com/video/BV1N741127Tj
		https://www.zhihu.com/question/381784377/answer/1099438784
        更改了亿点点代码
		*/
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int xx = 0;
            try
            {
                xx = int.Parse(textBox1.Text.Trim());
            }
            catch
            {
                try
                {
                    if (textBox1.Text.Trim().ToUpper().Substring(0, 2).Equals("AV"))
                    {
                        xx = int.Parse(textBox1.Text.Trim().Remove(0, 2));
                    }
                    else
                    {
                        MessageBox.Show("无效AV号");
                        return;
                    }
                }
                catch
                {
                    MessageBox.Show("无效AV号");
                    return;
                }
            }
            textBox2.Text = xx.toBV();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox2.Text.toAV();
        }
    }
}